import requests, json
from jsonpath import jsonpath


proxies = {
    'http': '127.0.0.1:10809',
    'https': '127.0.0.1:10809',
}
headers = {
    "Accept": "application/json",
    "X-API-KEY": "7b952a836b484c5e84e8171757aa69f0"
}
data_cursor = ''
while True:
    url = f"https://api.opensea.io/api/v1/events?asset_contract_address=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d&occurred_after=1656518400&cursor={data_cursor}"
    response = requests.get(url, headers=headers, proxies=proxies)
    data_cursor = jsonpath(json.loads(response.text), '$..next')[0]
    print(response.status_code)
    print(response.text)
    with open('./events.json', 'a') as file:
        file.write(response.text)
        if data_cursor == 'null':
            break
